import Repository from '@/utils/repository'
import {propertyDetails,PropertyListings } from '@/constants/defaultData';
// 运行时配置

// 全局初始化数据配置，用于 Layout 用户信息和权限初始化
// 更多信息见文档：https://umijs.org/docs/api/runtime-config#getinitialstate
export async function getInitialState(): Promise<{ name: string }> {
  return { name: '@umijs/max' };
}

export const layout = () => {
  //为了方便测试在这里先把数据插入本地数据库
  
  //初始化列表数据
  const DataRepository = new Repository('property')
  PropertyListings.forEach((item:any)=>{
    DataRepository.insert(item.id,item)
  })
  //初始化列表数据
  const DetailRepository = new Repository('property_detail')
  propertyDetails.forEach((item:any)=>{
    DetailRepository.insert(item.id,item)
  })
  return {
    logo: 'https://img.alicdn.com/tfs/TB1YHEpwUT1gK0jSZFhXXaAtVXa-28-27.svg',
    menu: {
      locale: false,
    },
  };
};
